<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Off the Record</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">

<script type="text/javascript">
	function init() {
		<c:set value="${adminVo.adminId }" var="admin"/>
		<c:set value="${userVo.userId }" var="user"/>
		var admin = "<c:out value="${admin}"/>";
		var user = "<c:out value="${user}"/>";
		if(user.length != 0 && admin.length == 0){
			alert("관리자 페이지입니다.");
			location.href="/OffTheRecord/index/index.jsp";
		}
		if(user.length == 0 && admin.length == 0){
			var c = confirm("관리자로 로그인 하시겠습니까?");
			if(c)
				location.href="/OffTheRecord/common/login.jsp";
			else
				location.href="/OffTheRecord/index/index.jsp";
		}
	}
	
 	$(document).ready(function() {
		$("#region_id").change(function(){
			$.ajax({
				type: "post",
				url: "/OffTheRecord/checkCompany.action",
				data: "companyName="+$('#company_name').val()+"&&regionName="+$('#region_id').val(),
				dataType:"json",
				
				success:function(data){
					if(data.message != null){
						alert(data.message);
						$('#company_name').val("");
						$('#region_id').val("");
					}
				}
			});//ajax
		});	
	}); 
	
	function checkInsert() {
		var f = document.registerForm;
		
		if(f.companyName.value == ""){
			alert("회사명을 입력하세요!");
			return f.companyName.focus();
		}else if(f.industryName.value == ""){
			alert("산업명을 입력하세요!");
			return f.industryName.focus();
		}else if(f.regionName.value == ""){
			alert("지역명을 입력하세요!");
			return f.regionName.focus();
		}else if(f.companyPresident.value == ""){
			alert("기업대표자를 입력하세요!");
			return f.companyPresident.focus();
		}else if(f.companySales.value == ""){
			alert("기업 매출액을 입력하세요!");
			return f.companySales.focus();
		}else if(f.companyInfo.value == ""){
			alert("회사 정보를 입력하세요!");
			return f.companyName.focus();
		}else if(f.companyUrl.value == ""){
			alert("회사 URL을 입력하세요!");
			return f.companyUrl.focus();
		}else if(f.companyAddress.value == ""){
			alert("기업 주소를 입력하세요!");
			return f.companyAddress.focus();
		}else if(f.companySalary.value == ""){
			alert("회사 연봉을 입력하세요!");
			return f.companySalary.focus();
		}else if(isNaN(f.companySales.value)){
			alert("기업 매출액은 숫자만 입력해 주세요!");
			f.companySales.value="";
			return f.companySales.focus();
		}else if(isNaN(f.companySalary.value)){
			alert("연봉은 숫자만 입력해 주세요!");
			f.companySalary.value="";
			return f.companySalary.focus();
		}
		alert("기업이 추가되었습니다.");
		f.submit();
	}
</script>
<body onload="init()">

<c:if test="${sessionScope.adminVo!=null && sessionScope.userVo == null }">
<c:import url="../common/top.jsp"></c:import>
<div class="container" style="margin: 60px;"></div>

<div class="container">
<div class="row">
<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>

<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
			
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
	<c:import url="admin_menu.jsp" />
</div>

<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">

	<!-- 탭 -->
	<div class="bs-example bs-example-tabs" role="tabpanel">
		<ul id="myTab" class="nav nav-tabs" role="tablist">
			<li role="presentation" class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" aria-expanded="true">기업추가</a></li>
	  	</ul>
	    
	    <div id="myTabContent" class="tab-content">
			<div role="tabpanel" class="tab-pane fade in active" id="home" aria-labelledBy="home-tab">
		   			
			<div class="user-update col-lg-12" style="padding: 10px;">
				<!--  -->
				<div class="bs-example">
					<form role="form" action="/OffTheRecord/registerCompany.action" method="post" name="registerForm" enctype="multipart/form-data">
						
						<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
							<div class="form-group">
								<label for="company_name">기업 명</label>
								<input type="text" class="form-control" id="company_name" placeholder="기업명을 입력해주세요" name="companyName">
							</div>
						</div>
						
						<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
							<div class="form-group">
								<label for="industry_id">산업 명</label>
								<input type="text" class="form-control" id="industry_id" list="industry" name="industryName" placeholder="산업명을 입력해주세요">
								<datalist id="industry">
									<c:forEach items="${listMap.industryList }" var="ilist">
										<option label="${ilist.industryName}" value="${ilist.industryName}" />
									</c:forEach>
								</datalist>
							</div>
						</div>
						
						<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
							<div class="form-group">
								<label for="region_id">지역 명</label>
								<input type="text" class="form-control" id="region_id" name="regionName" list="region" placeholder="지역명을 입력해주세요">
								<datalist id="region">
									<c:forEach items="${listMap.regionList }" var="rlist" varStatus="i">
										<option label="${rlist.regionName}" value="${rlist.regionName}" />
									</c:forEach>
								</datalist>
							</div>
						</div>
						
						<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
							<div class="form-group">
								<label for="company_president">기업 대표자</label>
								<input type="text" class="form-control" id="company_president" name="companyPresident" placeholder="기업 대표자의 이름을 입력해주세요.">
							</div>
						</div>
						
						<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
							<div class="form-group">
								<label for="company_sales">기업 매출액</label>
								<input type="text" class="form-control" id="company_sales" name="companySales" placeholder="숫자로 입력해주세요">
							</div>
						</div>
						
						<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
							<div class="form-group">
								<label for="company_salary">기업 연봉</label>
								<input type="text" class="form-control" id="company_salary" name="companySalary" placeholder="(단위:만)숫자로 입력해주세요">
							</div>
						</div>
						
						

							


							

							

							

							<div class="form-group">
								<label for="company_ci">기업 로고(company_ci)</label> <input
									type="file" id="company_ci" name="uploadFile">
								<p class="help-block">기업의 사진을 업로드해주세요.</p>
							</div>

							<div class="form-group">
								<label for="company_info">기업 정보(company_info)</label>
								<textarea class="form-control" rows="9" id="company_info"
									name="companyInfo" placeholder="기업정보을 입력해주세요."></textarea>
							</div>

							<div class="form-group">
								<label for="company_url">기업 URL(인터넷 주소)(company_url)</label> <input
									type="text" class="form-control" id="company_url"
									name="companyUrl" placeholder="기업URL을 입력해주세요.">
							</div>

							<div class="form-group">
								<label for="company_address">기업 주소(company_address)</label> <input
									type="text" class="form-control" id="company_address"
									name="companyAddress" placeholder="기업주소을 입력해주세요.">
							</div>

							

							<button type="button" class="btn btn-default"
								onclick="checkInsert()">회사 추가</button>
						</form>
					</div>
			<!--  -->
			</div>
						
			</div>
		</div>
	</div><!-- End 탭 -->

					
</div>

</div><!--  -->
<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>
</div><!-- row -->
</div><!-- container -->
</c:if>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> 
</body>
</html>